package com.westos.calcv3;

import com.westos.calcv2.IOperator;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class DivOperator implements IOperator,BeanNameAware,ApplicationContextAware {
    private String name;
    private ApplicationContext applicationContext;

    public DivOperator(){

    }

    public DivOperator(String name){
        this.name=name;
    }

//    public static DivOperator create(){
//        return new DivOperator("工厂方法");
//    }


    public Integer operator(Integer one, Integer two) {
        System.out.println("这是除法计算:"+this.name);
        return one/two;
    }

    public void setBeanName(String name) {
        System.out.println("name="+name);
        this.name=name;
    }

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("applicationContextAware的执行");
        this.applicationContext=applicationContext;
    }
}